﻿namespace Cherry.Models
{
    public static class Options
    {
        private static bool dirty = false;
        private static string _connectionString;
        private static ConfigurationManager cm;
        static Options()
        {
            cm = new ConfigurationManager();
            _connectionString = cm["ConnectionString"];
        }
        public static String ConnectionString
        {
            get
            {
                //如果配置文件更改过，则重新读取所有变量。
                LazyReloadOptions();

                return _connectionString;


            }
            set
            {
                _connectionString = value;
                dirty = true;
            }
        }

        private static void  LazyReloadOptions()
        {
            if (dirty)
            {
                _connectionString = cm["ConnectionString"];

                dirty = false;
            }
        }
    }
}
